<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <link href="../css/element.css" rel="stylesheet"/>
    <link href="../css/styleindex.css" rel="stylesheet"/>
    <link href="../css/swiper.min.css" rel="stylesheet"/>
    <style>
    .el-input__inner{
      border: 0;
      font-size: 1rem;
      text-align: center;
    }.el-input__prefix{
      display: none;
    }
    </style>
</head>
<body style="background:#EFF0F4;">

  <div class="mui-content">
    <div id="vm" class="x-examok" v-cloak>
      <div class="x-header-g" id="header">
        <a class="x-header-arrow" @click="api.closeWin()"></a>
        <div class="x-header-t">库房供货验收</div>
      </div>
        <div class="">
          <template>
            <el-table :data="tabledata">
              <el-table-column label="品名" width="90" fixed>
                <template slot-scope="scope">
                  {{scope.row.title}}
                </template>
              </el-table-column>
              <el-table-column label="存规格" width="">
                <template slot-scope="scope">
                  {{scope.row.save_unit}}
                </template>
              </el-table-column>
              <el-table-column label="库存量" width="">
                <template slot-scope="scope">
                  {{scope.row.store_num}}
                </template>
              </el-table-column>
              <el-table-column label="购规格" width="">
                <template slot-scope="scope">
                  {{scope.row.buy_unit}}
                </template>
              </el-table-column>
              <el-table-column label="审核量" width="130">
                <template slot-scope="scope">
                    {{scope.row.check_num}}
                </template>
              </el-table-column>
              <el-table-column label="验收量" width="130">
                <template slot-scope="scope">
                    <div v-if="noget==0" style="border:1px solid #058142;border-radius:.2rem;"><el-input v-model="scope.row.save_num" placeholder="请输入内容" type="number"></el-input></div>
                    <div v-else>
                        {{scope.row.save_num}}
                    </div>
                </template>
              </el-table-column>
              <el-table-column label="单价" width="130">
                <template slot-scope="scope">
                    <div v-if="noget==0" style="border:1px solid #058142;border-radius:.2rem;"><el-input v-model="scope.row.unit_price" placeholder="请输入内容" type="number"></el-input></div>
                    <div v-else>
                        {{scope.row.unit_price}}
                    </div>
                </template>
              </el-table-column>
              <el-table-column label="金额" width="">
                <template slot-scope="scope">
                  {{(scope.row.save_num*scope.row.unit_price).toFixed(2)}}
                </template>
              </el-table-column>
            </el-table>
          </template>
          <!-- <div class="x-table-desc">总金额：{{allmoney}}</div> -->
          <!-- <div class="x-table-desc">验收人：{{askname}}</div> -->
        </div>
        <!--  -->
        <div class="x-pro-gobtn" @click="isok">验收</div>
		
    </div>
  </div>

  <script type="text/javascript" src="../script/vue.js"></script>
  <script type="text/javascript" src="../script/element.js"></script>
  <script type="text/javascript" src="../script/api.js"></script>
  <script type="text/javascript" src="../script/base.js"></script>
  <script type="text/javascript" src="../script/jquery-1.11.1.min.js"></script>
  <script type="text/javascript" src="../script/swiper.min.js"></script>
	<script>
apiready = function () {
    $api.fixStatusBar($api.byId('header'));
    var tsupplierid = api.pageParam.supplierid;
    var tfordata = api.pageParam.fordata;
    var ttime = api.pageParam.time;


    //
    var vm = new Vue({
      el:'#vm',
      data(){
        return{
          tabsdata:'',
          curId:0,
          tabledata:[],
          cardsmonth:'',
          cardsmonthtoy:'',
          cardsmonthtom:'',
          tabsid:0,
          notkey:false,
          isfromindex:true,
          noget:0,
          askname:'',
          yesshow:false,
          noshow:false,
          checkname:'',
          savename:'',
          allmoney:0,
          thid:'',
          isclick:true,
        }
      },
      created:function() {
        var that=this;


      },
      mounted:function(){
        var that=this;
        that.thsupplierid = tsupplierid;
        that.thfordata = tfordata;
        that.tabledata = that.thfordata.list;
        console.log(JSON.stringify(that.tabledata));
        that.askname = that.thfordata.save_username;
        that.thtime = ttime;
        //当前月份
        var date = new Date();
        var year = date.getFullYear();
        var month = date.getMonth()+1;
        var day = date.getDate();
        if(month<10){
          month = '' + 0 + month;
        }
        if(day<10){
          day = '' + 0 + day;
        }
        var toMonth = '' + year + month + day;
        that.cardsmonth = toMonth;
      },
      methods: {
        //提交
        isok:function(){
          let that=this;
          if(that.isclick){
            that.isclick = false
            api.ajax({
              url:baseurl+'api/material/addWarehouseSave?sec=' + $api.getStorage('apptoken') + '&supplierid=' + that.thsupplierid + '&date=' + that.thtime,
              method:'post',
              data:{
                values:{
                  num_json:that.tabledata
                }
              }
            },function(ret,err){
              if(ret){
                api.hideProgress();
                console.log(JSON.stringify(ret));
                if(ret.status == 1){
                  api.toast({
                      msg: ret.msg,
                      duration: 3000,
                      location: 'bottom'
                  });
                  api.sendEvent({
                      name: 'housecheckbeforesucc',
                      extra: {
                        
                      }
                  });
                  setTimeout(function(){
                      api.closeWin()
                  },1000)
                }else{
                  api.toast({
                      msg: ret.msg,
                      duration: 3000,
                      location: 'bottom'
                  });
                }
              }else{
                api.hideProgress();
                console.log(JSON.stringify(err));
                api.toast({
                    msg: err.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            })
          }
          
        },
      }
    })
	}

	</script>
</body>
</html>
